﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;
using Shop.Model.Custom;
namespace Shop.Framework.Runtime {

    public class CMSFilter : ActionFilterAttribute {

        public override void OnActionExecuted(ActionExecutedContext filterContext) {

            if (CMSRuntime.Instance.IsLoggedIn())
                base.OnActionExecuted(filterContext);
            else {
                filterContext.Canceled = true;
                HttpContext.Current.Response.Redirect("/cms/login");
            }
           
        }
    }

    public class PaymentFilter : ActionFilterAttribute {

        public override void OnActionExecuted(ActionExecutedContext filterContext) {
            if (WebCart.Self.IsLoggedIn)
                base.OnActionExecuted(filterContext);
            else {
                filterContext.Canceled = true;
                HttpContext.Current.Session["FromCheckout"] = 1;
                HttpContext.Current.Response.Redirect("/register.html");
            }
        }

    }
}
